package com.lanchetech.user.controller;

import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.CustomPageEditVO;
import com.lanchetech.entity.HipoConfig;
import com.lanchetech.entity.OnePost;
import com.lanchetech.entity.Poster;
import com.lanchetech.entity.WebConfig;
import com.lanchetech.user.service.WebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "网站配置接口", tags = "网站配置")
@RequestMapping("/api/web")
@RestController
public class WebController {

    @Autowired
    WebService webService;

    @ApiOperation("获取所有网站配置")
    @GetMapping("/getWebConfigList")
    public ResultData<List<WebConfig>> getWebConfigList() {
        return webService.getWebConfigList();
    }

    @ApiOperation("获取自定义专题详情")
    @GetMapping("/getCustomPageDetail")
    public ResultData<CustomPageEditVO> getCustomPageDetail(@RequestParam("id") Long id) {
        return webService.getCustomPageDetail(id);
    }

    @ApiOperation("获取推广海报分页")
    @PostMapping("/getPosterPage")
    public ResultData<BasePageResp<Poster>> getPosterPage(@RequestBody PageReq req) {
        return webService.getPosterPage(req);
    }

    @ApiOperation(value = "获取指定配置")
    @GetMapping("/getWebConfigByName")
    public ResultData<String> getWebConfigByName(@RequestParam("name") String name) {
        return webService.getWebConfigByName(name);
    }

    @ApiOperation("获取一键发圈分页")
    @PostMapping("/getOnePostPage")
    public ResultData<BasePageResp<OnePost>> getOnePostPage(@RequestBody PageReq req) {
        return webService.getOnePostPage(req);
    }

    @ApiOperation("获取所有嗨跑分销配置")
    @GetMapping("/getHipoConfigList")
    public ResultData<List<HipoConfig>> getHipoConfigList() {
        return webService.getHipoConfigList();
    }

}
